cd "C:\Users\marku\Dropbox\Fiscal Consolidation 3\Papers\Paper 3\CPS\replication\"

log using appendix.txt, replace

*** POOLED RESULTS 
 
use "IMF_Greece.dta", clear

gen country=1

append using "IMF_Portugal.dta"
replace country=2 if country==. 
 append using "IMF_Spain.dta"
 replace country=3 if country==. 
append using  "IMF_Ireland.dta"
replace country=4 if country==. 

label define country 1 "GR" 2 "PT" 3 "ES" 4 "IE"
label values country country



gen main_rad=.
replace main_rad=0 if vote_family==1|vote_family==4
replace main_rad=1 if vote_family==2|vote_family==6
replace main_rad=2 if vote_family==3|vote_family==7

label define main_rad 0 "Mainstream" 1 "Radical", replace
label values main_rad main_rad
label variable main_rad "Party vote"
tab inc5, gen(inccat)
tab govmatch, gen(govmatchcat)
tab isced4, gen(iscedcat)
tab country, gen(countrycat)
gen inteffect1=rndm_party*govmatchcat1
gen inteffect2=rndm_party*govmatchcat2

** Table C1: Balance test
label define treatment 0 "no" 1 "yes"
label values imf treatment
label variable imf "IMF treatment"

gen gender_desc=0 if Q2_2==1
label variable gender_desc "Female"
replace gender_desc=1 if Q2_2==2
gen isced_descr=isced4 if isced4!=4
label variable isced_descr "Education, 3 cats"
gen inc_descr=inc5 if inc5!=5
label variable inc_descr "Income, 4 cats"

table (var) (imf), statistic(mean gender_desc Q2_3 Q3_5 isced_descr inc_descr) statistic(sd Q2_3 Q3_5 isced_descr inc_descr) statistic(n gender_desc Q2_3 Q3_5 isced_descr inc_descr)  nformat(%6.2f)
collect preview
collect export descr_overall.tex, tableonly replace
table (var) (imf) if country==1, statistic(mean gender_desc Q2_3 Q3_5 isced_descr inc_descr) statistic(sd Q2_3 Q3_5 isced_descr inc_descr) statistic(n gender_desc Q2_3 Q3_5 isced_descr inc_descr)  nformat(%6.2f)
collect preview
collect export descr_gr.tex, tableonly replace
table (var) (imf)  if country==2, statistic(mean gender_desc Q2_3 Q3_5 isced_descr inc_descr) statistic(sd Q2_3 Q3_5 isced_descr inc_descr) statistic(n gender_desc Q2_3 Q3_5 isced_descr inc_descr)  nformat(%6.2f)
collect preview
collect export descr_pt.tex, tableonly replace
table (var) (imf) if country==3, statistic(mean gender_desc Q2_3 Q3_5 isced_descr inc_descr) statistic(sd Q2_3 Q3_5 isced_descr inc_descr) statistic(n gender_desc Q2_3 Q3_5 isced_descr inc_descr)  nformat(%6.2f)
collect preview
collect export descr_es.tex, tableonly replace
table (var) (imf) if country==4, statistic(mean gender_desc Q2_3 Q3_5 isced_descr inc_descr) statistic(sd Q2_3 Q3_5 isced_descr inc_descr) statistic(n gender_desc Q2_3 Q3_5 isced_descr inc_descr)  nformat(%6.2f)
collect preview

collect export TableC1.tex, tableonly replace

*** Table C2: Descriptives of approval variable

ttest IMFQ1_1, by(imf)  
matrix b=r(mu_2)-r(mu_1)
matrix a=(b,r(se),r(mu_1),r(N_1),r(mu_2),r(N_2),r(df_t))
matrix a=a'
forvalues x=1(1)4 {
ttest IMFQ1_1 if country==`x', by(imf)  
matrix b`x'=r(mu_2)-r(mu_1)
matrix a`x'=(b`x',r(se),r(mu_1),r(N_1),r(mu_2),r(N_2),r(df_t))
matrix a`x'=a`x''
}
matrix a=a,a1,a2,a3,a4
matrix list a
matrix colnames a = Full Greece Portugal Spain Ireland
matrix rownames a = Difference SE Control N(Control) Treatment N(Treatment) N(Overall) 
esttab matrix(a, fmt( %9.2f)) using TableC2.tex, replace tex 


*** Table D.3: Regression results, approval of policy
local othtreat "rndm_publicdebt rndm_party rndm_spendingcuts"
local controls "Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_withoutcountry "Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch"

reg IMFQ1_1 imf `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_1 imf `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}

esttab m0 m1 m2 m3 m4 using TableD3.tex, nonumber mtitles(Overall Greece Portugal Spain Ireland) coeflabels(imf "IMF treatment" rndm_publicdebt "Public debt" rndm_party "Party in Gov" rndm_spendingcuts "Spending cuts" Q2_2 "Female" Q2_3 "Age (7 cats)" Q3_5 "L-R self-placement" 1.pubsec "Public sector" econideology "Economic ideology" nattrust "Trust, national" inttrust "Trust, international" 2.country "Portugal" 3.country "Spain" 4.country "Ireland" 2.inc5 "Income, 2nd quartile" 3.inc5 "Income, 3rd quartile" 4.inc5 "Income, 4th quartile" 5.inc5 "Income, refused" 1.govmatch "Gov voter" 2.govmatch "Opp voter" 2.isced4 "ISCED 3-5" 3.isced4 "ISCED 6-8" 4.isced4 "ISCED missing" 1.rndm_party#1.govmatch "Gov party x Gov vote" 1.rndm_party#2.govmatch "Gov party x Opp vote") nobaselevels drop(1.rndm_party) se tex replace


*** Table D4: Regression results, heterogeneous treatment effects

reg IMFQ1_1 i.imf##c.Q3_5    i.imf##c.inttrust  i.rndm_publicdebt i.rndm_party i.rndm_spendingcuts Q2_2 Q2_3 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust  i.rndm_party##ib3.govmatch  i.country 
estimates store m1
reg IMFQ1_1  i.imf##c.econideology  i.imf##c.inttrust  i.rndm_publicdebt i.rndm_party i.rndm_spendingcuts Q2_2 Q2_3 i.pubsec i.inc5 ib3.govmatch i.isced4  nattrust  i.rndm_party##ib3.govmatch  i.country
estimates store m2
reg IMFQ1_1 i.imf##i.govmatch i.rndm_publicdebt i.rndm_party i.rndm_spendingcuts Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country 
estimates store m3
reg IMFQ1_1 i.imf##ib2.main_rad i.imf##ib3.govmatch i.rndm_publicdebt i.rndm_party i.rndm_spendingcuts Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country if country!=4 
estimates store m4


esttab m1 m2 m3 m4 using TableD4.tex, nonumber mtitles(LR/Trust "Econ ideology" "Gov match" "Radical vote") coeflabels(imf "IMF treatment" 1.rndm_publicdebt "Public debt" 1.rndm_party "Party in Gov" 1.rndm_spendingcuts "Spending cuts" Q2_2 "Female" Q2_3 "Age (7 cats)" Q3_5 "L-R self-placement" 1.pubsec "Public sector" econideology "Economic ideology" nattrust "Trust, national" inttrust "Trust, international" 2.country "Portugal" 3.country "Spain" 4.country "Ireland" 2.inc5 "Income, 2nd quartile" 3.inc5 "Income, 3rd quartile" 4.inc5 "Income, 4th quartile" 5.inc5 "Income, refused" 1.govmatch "Gov voter" 2.govmatch "Opp voter" 2.isced4 "ISCED 3-5" 3.isced4 "ISCED 6-8" 4.isced4 "ISCED missing" 1.rndm_party#1.govmatch "Gov party x Gov vote" 1.rndm_party#2.govmatch "Gov party x Opp vote" 1.imf#c.Q3_5 "Treatment x LR position" 1.imf#c.econideology "Treatment x Econ ideology" 1.imf#c.inttrust "Treatment x Trust, int" 1.imf#1.govmatch "Treatment x Gov vote" 1.imf#2.govmatch "Treatment x Opp vote" 0.main_rad "Mainstream voter" 1.main_rad "Radical voter" 1.imf#0.main_rad "Treatment x Mainstream" 1.imf#1.main_rad "Treatment x Radical") nobaselevels drop(1.rndm_party) se order(1.imf Q3_5 econideology inttrust 1.imf#c.Q3_5 1.imf#c.econideology 1.imf#c.inttrust 1.govmatch 2.govmatch 1.imf#1.govmatch 1.imf#2.govmatch 0.main_rad 1.main_rad 1.imf#0.main_rad 1.imf#1.main_rad) tex replace


*** Table D5: ACME, all mediators
local othtreat "rndm_publicdebt rndm_party rndm_spendingcuts"
local controls "Q2_2 Q2_3 Q3_5 pubsec  govmatchcat1-govmatchcat2 iscedcat1-iscedcat3 econideology nattrust inttrust inteffect1 inteffect2 countrycat1-countrycat3"  
local controls_withoutcountry "Q2_2 Q2_3 Q3_5 pubsec  govmatchcat1-govmatchcat2 iscedcat1-iscedcat3 econideology nattrust inttrust inteffect1 inteffect2 "
local mediators "IMFQ2_1 IMFQ2_2 IMFQ2_3 IMFQ2_4"

*** KEY CONTROLS
forvalues x = 1/4 {
medeff (regress IMFQ2_`x' imf  `othtreat' `controls') (regress IMFQ1_1 IMFQ2_`x' imf  `othtreat' `controls'), mediate(IMFQ2_`x') treat(imf) sims(2000) seed(12345)
matrix a`x'=`x', r(delta0), r(delta0lo), r(delta0hi) , r(zeta0), r(zeta0lo), r(zeta0hi) , r(tau), r(taulo), r(tauhi)
*medsens (regress IMFQ2_`x' imf  `othtreat' `controls') (regress IMFQ1_1 IMFQ2_`x' imf  `othtreat' `controls'), mediate(IMFQ2_`x') treat(imf) sims(2000) 
*by country
forvalues y = 1/4 {
preserve
drop if country!=`y'	
medeff (regress IMFQ2_`x' imf  `othtreat' `controls_withoutcountry') (regress IMFQ1_1 IMFQ2_`x' imf `othtreat' `controls_withoutcountry'), mediate(IMFQ2_`x') treat(imf) sims(2000) seed(12345)
matrix b`x'`y'=`y', r(delta0), r(delta0lo), r(delta0hi) , r(zeta0), r(zeta0lo), r(zeta0hi) , r(tau), r(taulo), r(tauhi)

*medsens (regress IMFQ2_`x' imf `othtreat' `controls_withoutcountry') (regress IMFQ1_1 IMFQ2_`x' imf `othtreat' `controls_withoutcountry'), mediate(IMFQ2_`x') treat(imf) sims(2000) 

restore
}
}

matrix r=a1\a2\a3\a4
svmat r

label define mediator 1 "Competence" 2 "Effectiveness" 3 "Sovereignty" 4 "Accountability", replace
label values r1 mediator

matrix comp=a1\b11\b12\b13\b14
svmat comp
replace comp1=_n if comp1!=.

matrix succ=a2\b21\b22\b23\b24
svmat succ
replace succ1=_n if succ1!=.

matrix room=a3\b31\b32\b33\b34
svmat room
replace room1=_n if room1!=.

matrix repr=a4\b41\b42\b43\b44
svmat repr
replace repr1=_n if repr1!=.

mkmat comp2-comp7 if _n<6, matrix(comp)
mkmat succ2-succ7  if _n<6, matrix(succ)
mkmat room2-room7  if _n<6, matrix(room)
mkmat repr2-repr7 if _n<6, matrix(repr)
matrix a=comp\succ\room\repr
matrix list a
matrix colnames a = "Mediated effect" "95 CI: Lower bound"  "95 CI: Upper bound" "Direct effect" "95 CI: Lower bound"  "95 CI: Upper bound"
matrix rownames a = Competence Competence(Greece) Competence(Portugal) Competence(Spain) Competence(Ireland) ///
Effectiveness Effectiveness(Greece) Effectiveness(Portugal) Effectiveness(Spain) Effectiveness(Ireland) ///
Sovereignty Sovereignty(Greece) Sovereignty(Portugal) Sovereignty(Spain) Sovereignty(Ireland) ///
Accountability Accountability(Greece) Accountability(Portugal) Accountability(Spain) Accountability(Ireland)
 
esttab matrix(a, fmt( %9.2f)) using TableD5.tex, replace tex 

drop comp* succ* repr* room* r1-r10


*** APPENDIX E

label define govmatch 1 "Gov voter" 2 "Opp voter" 3 "Other", replace
label values govmatch govmatch

local othtreat "rndm_publicdebt i.rndm_party rndm_spendingcuts"
local controls "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_withoutcountry "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch"

reg IMFQ1_2 i.imf##i.govmatch `othtreat'  `controls' // 1 voted for gov party, 2 voted for opp party, 3 other
margins, dydx(imf) at(govmatch=(1 2 3)) post
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_2 imf##i.govmatch `othtreat' `controls_withoutcountry' if country==`x'
margins, dydx(imf) at(govmatch=(1 2 3)) post
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
scheme(plotplain)  nokey ///
xline(0, lpattern(dash)) yline(1.50, lpattern(solid)) yline(2.5, lpattern(solid)) title("IMF treatment on vote")  levels(99 95) legend(off)coeflabels(1._at="Left Gov" 2._at="Right gov") ///
msymbol(O) mcolor(black)  ///
xtitle("<<< less likely to vote for gov. || more likely to vote for gov. >>>") ///
 ylabel(.66 "Overall, Gov voter" .83 "Greece, Gov voter" ///
 1 "Portugal, Gov voter" 1.17 "Spain, Gov voter" ///
 1.34 "Ireland, Gov voter" 1.67 "Overall, Opp voter" ///
 1.84 "Greece, Opp voter" 2.01 "Portugal, Opp voter" ///
 2.18 "Spain, Opp voter" 2.35 "Ireland, Opp voter" ///
 2.67 "Overall, Indep" ///
 2.84 "Greece, Indep" 3.01 "Portugal, Indep" ///
 3.18 "Spain, Indep" 3.35 "Ireland, Indep" ///
 ) yscale(range(.5 1.5))
graph export FigureE1.png, replace

*** Appendix F
local othtreat "rndm_publicdebt i.rndm_party rndm_spendingcuts"
local controls "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_withoutcountry "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch"

reg IMFQ1_1 imf `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_1 imf `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
keep(rndm_publicdebt rndm_spendingcuts 1.rndm_party#1.govmatch 1.rndm_party#2.govmatch) ///
scheme(plotplain) ///
xline(0, lpattern(dash)) yline(.75, lpattern(solid))   levels(99 95) legend(off) ///
msymbol(O) mcolor(black) bycoefs ///
xtitle("<<< lower approval || higher approval >>>")  nokey ///
 coeflabels(rndm_publicdebt ="High public debt" rndm_spendingcuts="Large spending cuts" ///
 1.rndm_party#1.govmatch = "Gov party support" ///
 1.rndm_party#2.govmatch = "Opp party support") ///
 ylabel(.66 "Overall" .83 "Greece" 1 "Portugal" 1.17 "Spain" 1.34 "Ireland") yscale(range(.5 1.5))
graph export FigureF2.png, replace


local othtreat "rndm_publicdebt rndm_party rndm_spendingcuts"
local controls "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local othtreat_interactions "i.imf##i.rndm_publicdebt i.imf##i.rndm_party i.imf##i.rndm_spendingcuts"


reg IMFQ1_1 `othtreat_interactions' `controls'
margins, dydx(imf) at(rndm_publicdebt=(0 1))  post
estimates store m0
reg IMFQ1_1 `othtreat_interactions' `controls'
margins, dydx(imf) at(rndm_spendingcuts=(0 1))  post
estimates store m1
reg IMFQ1_1 `othtreat_interactions' `controls' if country!=4
margins, dydx(imf) at(rndm_party=(0 1))  post
estimates store m2


coefplot m0 , ///
scheme(plotplain) ///
xline(0, lpattern(dash))  levels(99 95) legend(off) ///
msymbol(O) mcolor(black)   ///
xtitle("Policy approval") nokey ///
 ylabel(1 "Moderate" 2 "Massive") title("Public debt") yscale(range(.5 1.5)) saving(1.gph, replace)
 
 coefplot m1 , ///
scheme(plotplain) ///
xline(0, lpattern(dash))  levels(99 95) legend(off) ///
msymbol(O) mcolor(black)   ///
xtitle("Policy approval") nokey ///
 ylabel(1 "Moderate" 2 "Massive") title("Spending cuts") yscale(range(.5 1.5)) saving(2.gph, replace)
 
 coefplot m2 , ///
scheme(plotplain) ///
xline(0, lpattern(dash))  levels(99 95) legend(off) ///
msymbol(O) mcolor(black)   ///
xtitle("Policy approval") nokey ///
 ylabel(1 "CR Government" 2 "CL Government") title("Government orientation") yscale(range(.5 1.5)) saving(3.gph, replace)
 
 
 graph combine 1.gph 2.gph 3.gph, title("IMF treatment effect" "interacted with other conditions") scheme(plotplain) r(1)
graph export FigureF3.png, replace



local othtreat "rndm_publicdebt rndm_party rndm_spendingcuts"
local controls "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local othtreat_interactions "i.imf##i.rndm_publicdebt i.imf##i.rndm_party i.imf##i.rndm_spendingcuts"

reg IMFQ2_2 imf `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ2_2 imf `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}


esttab m0 m1 m2 m3 m4 using TableF6.tex, nonumber mtitles(Overall Greece Portugal Spain Ireland) coeflabels(imf "IMF treatment" rndm_publicdebt "Public debt" rndm_party "Party in Gov" rndm_spendingcuts "Spending cuts" Q2_2 "Female" Q2_3 "Age (7 cats)" Q3_5 "L-R self-placement" 1.pubsec "Public sector" econideology "Economic ideology" nattrust "Trust, national" inttrust "Trust, international" 2.country "Portugal" 3.country "Spain" 4.country "Ireland" 2.inc5 "Income, 2nd quartile" 3.inc5 "Income, 3rd quartile" 4.inc5 "Income, 4th quartile" 5.inc5 "Income, refused" 1.govmatch "Gov voter" 2.govmatch "Opp voter" 2.isced4 "ISCED 3-5" 3.isced4 "ISCED 6-8" 4.isced4 "ISCED missing" 1.rndm_party#1.govmatch "Gov party x Gov vote" 1.rndm_party#2.govmatch "Gov party x Opp vote") nobaselevels drop(1.rndm_party) se tex replace



reg IMFQ2_4 imf `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ2_4 imf `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
esttab m0 m1 m2 m3 m4 using TableF7.tex, nonumber mtitles(Overall Greece Portugal Spain Ireland) coeflabels(imf "IMF treatment" rndm_publicdebt "Public debt" rndm_party "Party in Gov" rndm_spendingcuts "Spending cuts" Q2_2 "Female" Q2_3 "Age (7 cats)" Q3_5 "L-R self-placement" 1.pubsec "Public sector" econideology "Economic ideology" nattrust "Trust, national" inttrust "Trust, international" 2.country "Portugal" 3.country "Spain" 4.country "Ireland" 2.inc5 "Income, 2nd quartile" 3.inc5 "Income, 3rd quartile" 4.inc5 "Income, 4th quartile" 5.inc5 "Income, refused" 1.govmatch "Gov voter" 2.govmatch "Opp voter" 2.isced4 "ISCED 3-5" 3.isced4 "ISCED 6-8" 4.isced4 "ISCED missing" 1.rndm_party#1.govmatch "Gov party x Gov vote" 1.rndm_party#2.govmatch "Gov party x Opp vote") nobaselevels drop(1.rndm_party) se tex replace


* Figure F4
local othtreat "rndm_publicdebt rndm_party "
local controls "Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_withoutcountry "Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch"


reg IMFQ1_1 i.imf##i.rndm_spendingcuts `othtreat' `controls'
margins, dydx(imf) at(rndm_spendingcuts=(0 1)) post
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_1 i.imf##i.rndm_spendingcuts `othtreat' `controls_withoutcountry' if country==`x'
margins, dydx(imf) at(rndm_spendingcuts=(0 1)) post
estimates store m`x'
}

coefplot m0 m1 m2 m3 m4, ///
scheme(plotplain)  nokey ///
xline(0, lpattern(dash)) yline(1.50, lpattern(solid)) yline(2.5, lpattern(solid)) title("IMF treatment on approval, by fiscal adjustment")  levels(99 95) legend(off) ///
msymbol(O) mcolor(black)  ///
xtitle("<<< lower approval || higher approval >>>") ///
 ylabel(.66 "Overall, Low" .83 "Greece, Low" ///
 1 "Portugal, Low" 1.17 "Spain, Low" ///
 1.34 "Ireland, Low" 1.67 "Overall, High" ///
 1.84 "Greece, High" 2.01 "Portugal, High" ///
 2.18 "Spain, High" 2.35 "Ireland, High" ///
 ) yscale(range(.5 1.5))
graph export FigureF4.png, replace

* Figure F5
local othtreat "i.rndm_publicdebt i.rndm_party i.rndm_spendingcuts"
local controls "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_nolr "Q2_2 i.Q2_3  i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"
local controls_withoutcountry "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch" 


reg IMFQ1_1 i.imf##c.goveconcom i.imf##i.govmatch `othtreat' `controls'
margins, dydx(imf) at(goveconcom=(1(1)5))
marginsplot, scheme(plotplain) recastci(rline) ciopts(lpattern(dash_dot)) recast(line) ///
 title(HTE by economic conf in govt) xtitle("Economic confidence in government") aspectratio(0.5)   ///
 ytitle("Treatment effect") yline(0, lpattern(dash)) ///
 addplot(hist goveconcom,  yaxis(2) bin(11) percent yscale(range(0 100) axis(2)) ylabel("", axis(2)) ylabel(-.5 (.5) 1)  yscale(range(-.5 1) axis(1)) ytitle("", axis(2)))  legend(off) saving(0c.gph, replace)

graph export FigureF5.png, replace


*** EFFECTS OF MEDIATORS ON OUTCOME

local othtreat "rndm_publicdebt rndm_party rndm_spendingcuts"
local controls "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_withoutcountry "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch"
local mediators "IMFQ2_1 IMFQ2_2 IMFQ2_3 IMFQ2_4"


*Each individually
reg IMFQ1_1 imf IMFQ2_1  `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_1 imf IMFQ2_1 `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
keep(IMFQ2_1) ///
scheme(plotplain) ///
yline(.75, lpattern(solid))   levels(99 95) legend(off) ///
msymbol(O) mcolor(black) bycoefs ///
xtitle("<<< lower approval || higher approval >>>") nokey ///
 coeflabels(IMFQ2_1 ="Competence") xscale(range(0 1)) xlabel(0(.1)1) title("Competence") ///
 ylabel(.66 "Overall" .83 "Greece" 1 "Portugal" 1.17 "Spain" 1.34 "Ireland") yscale(range(.5 1.5))  saving(1.gph, replace)

reg IMFQ1_1 imf IMFQ2_2  `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_1 imf IMFQ2_2 `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
keep(IMFQ2_2) ///
scheme(plotplain) ///
yline(.75, lpattern(solid))   levels(99 95) legend(off) ///
msymbol(O) mcolor(black) bycoefs ///
xtitle("<<< lower approval || higher approval >>>") nokey ///
 coeflabels(IMFQ2_2 ="Effectiveness") xscale(range(0 1)) xlabel(0(.1)1) title("Effectiveness") ///
 ylabel(.66 "Overall" .83 "Greece" 1 "Portugal" 1.17 "Spain" 1.34 "Ireland") yscale(range(.5 1.5)) saving(2.gph, replace)

reg IMFQ1_1 imf IMFQ2_3  `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_1 imf IMFQ2_3 `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
keep(IMFQ2_3) ///
scheme(plotplain) ///
yline(.75, lpattern(solid))   levels(99 95) legend(off) ///
msymbol(O) mcolor(black) bycoefs ///
xtitle("<<< lower approval || higher approval >>>") nokey ///
 coeflabels(IMFQ2_3 ="Sovereignty") xscale(range(0 1)) xlabel(0(.1)1) title("Sovereignty") ///
 ylabel(.66 "Overall" .83 "Greece" 1 "Portugal" 1.17 "Spain" 1.34 "Ireland") yscale(range(.5 1.5))  saving(3.gph, replace)

reg IMFQ1_1 imf IMFQ2_4 `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ1_1 imf IMFQ2_4 `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
keep(IMFQ2_4) ///
scheme(plotplain) ///
yline(.75, lpattern(solid))   levels(99 95) legend(off) ///
msymbol(O) mcolor(black) bycoefs ///
xtitle("<<< lower approval || higher approval >>>") nokey ///
 coeflabels(IMFQ2_4 ="Accountability") xscale(range(0 1)) xlabel(0(.1)1) title("Accountability") ///
 ylabel(.66 "Overall" .83 "Greece" 1 "Portugal" 1.17 "Spain" 1.34 "Ireland") yscale(range(.5 1.5))  saving(4.gph, replace)

graph combine 1.gph 2.gph 3.gph 4.gph, col(2) scheme(plotplain)
graph export FigureF6.png, replace


*** Figure F7
local othtreat "rndm_publicdebt rndm_party rndm_spendingcuts"
local controls "Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_withoutcountry "Q2_2 Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch"

reg IMFQ2_1 imf `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ2_1 imf `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
keep(imf) ///
scheme(plotplain) ///
xline(0, lpattern(dash)) yline(.75, lpattern(solid)) xscale(range(-1 .7)) xlabel(-1(.2).7) title("IMF treatment on competence")  levels(99 95) legend(off) ///
msymbol(O) mcolor(black)  ///
xtitle("<<< less competent || more competent >>>") ///
 ylabel(.66 "Overall" .83 "Greece" 1 "Portugal" 1.17 "Spain" 1.34 "Ireland") yscale(range(.5 1.5)) saving(1.gph, replace)
reg IMFQ2_4 imf `othtreat' `controls'
estimates store m0
forvalues x = 1/4 {
reg IMFQ2_4 imf `othtreat' `controls_withoutcountry' if country==`x'
estimates store m`x'
}
coefplot m0 m1 m2 m3 m4, ///
keep(imf) ///
scheme(plotplain) ///
xline(0, lpattern(dash)) xscale(range(-1 .7)) xlabel(-1(.2).7) yline(.75, lpattern(solid)) title("IMF treatment on accountability")  levels(99 95) legend(off) ///
msymbol(O) mcolor(black)  ///
xtitle("<<< lower match w/ voters || higher match w/ voters  >>>") ///
 ylabel(.66 "Overall" .83 "Greece" 1 "Portugal" 1.17 "Spain" 1.34 "Ireland") yscale(range(.5 1.5)) saving(4.gph, replace)

graph combine  1.gph 4.gph  , row(1) scheme(plotplain) note("Note: 99% and 95% CIs shown", size(vsmall))
graph export FigureF7.png, replace width(3600)



***FIGURE F8
local othtreat "rndm_publicdebt rndm_party rndm_spendingcuts"
local controls "Q2_2 Q2_3 Q3_5 pubsec  govmatchcat1-govmatchcat2 iscedcat1-iscedcat3 econideology nattrust inttrust inteffect1 inteffect2 countrycat1-countrycat3"  
local controls_withoutcountry "Q2_2 Q2_3 Q3_5 pubsec  govmatchcat1-govmatchcat2 iscedcat1-iscedcat3 econideology nattrust inttrust inteffect1 inteffect2 "
local mediators "IMFQ2_1 IMFQ2_2 IMFQ2_3 IMFQ2_4"


forvalues x = 1/4 {
medeff (regress IMFQ2_`x' imf  `othtreat' `controls') (regress IMFQ1_1 IMFQ2_`x' imf  `othtreat' `controls'), mediate(IMFQ2_`x') treat(imf) sims(2000) seed(12345)
matrix a`x'=`x', r(delta0), r(delta0lo), r(delta0hi) , r(zeta0), r(zeta0lo), r(zeta0hi) , r(tau), r(taulo), r(tauhi)
*medsens (regress IMFQ2_`x' imf  `othtreat' `controls') (regress IMFQ1_1 IMFQ2_`x' imf  `othtreat' `controls'), mediate(IMFQ2_`x') treat(imf) sims(2000) 
*by country
forvalues y = 1/4 {
preserve
drop if country!=`y'	
medeff (regress IMFQ2_`x' imf  `othtreat' `controls_withoutcountry') (regress IMFQ1_1 IMFQ2_`x' imf `othtreat' `controls_withoutcountry'), mediate(IMFQ2_`x') treat(imf) sims(2000) seed(12345)
matrix b`x'`y'=`y', r(delta0), r(delta0lo), r(delta0hi) , r(zeta0), r(zeta0lo), r(zeta0hi) , r(tau), r(taulo), r(tauhi)

*medsens (regress IMFQ2_`x' imf `othtreat' `controls_withoutcountry') (regress IMFQ1_1 IMFQ2_`x' imf `othtreat' `controls_withoutcountry'), mediate(IMFQ2_`x') treat(imf) sims(2000) 

restore
}
}

matrix r=a1\a2\a3\a4
svmat r

label define mediator 1 "Competence" 2 "Effectiveness" 3 "Sovereignty" 4 "Accountability", replace
label values r1 mediator
matrix comp=a1\b11\b12\b13\b14
svmat comp
replace comp1=_n if comp1!=.
graph twoway (scatter  comp1 comp2) (rcap  comp3 comp4 comp1, horizontal), scheme(plotplain) ///
legend(off) title(Competence) ytitle("") yline(1.5, lpattern(dash)) ylabel(1 "Overall" 2 "Greece" 3 "Portugal" 4 "Spain" 5 "Ireland") ///
xline(0, lpattern(dash)) xscale(range(-.35 .35)) xlabel(-.35(.1).35) ysc(reverse) saving(1.gph, replace)
matrix repr=a4\b41\b42\b43\b44
svmat repr
replace repr1=_n if repr1!=.
graph twoway (scatter  repr1 repr2) (rcap  repr3 repr4 repr1, horizontal), scheme(plotplain) ///
legend(off) title(Accountability) ytitle("") yline(1.5, lpattern(dash)) ylabel(1 "Overall" 2 "Greece" 3 "Portugal" 4 "Spain" 5 "Ireland") ///
xline(0, lpattern(dash)) xscale(range(-.35 .35)) xlabel(-.35(.1).35) ysc(reverse) saving(4.gph, replace)
graph combine  1.gph 4.gph , row(1) scheme(plotplain) note("Note: 95% CIs shown", size(vsmall))
graph export FigureF8.png, replace width(3600)


*** Figure F9
local othtreat "i.rndm_publicdebt i.rndm_party i.rndm_spendingcuts"
local controls "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"  
local controls_nolr "Q2_2 i.Q2_3  i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch  i.country"
local controls_withoutcountry "Q2_2 i.Q2_3 Q3_5 i.pubsec i.inc5 ib3.govmatch i.isced4 econideology nattrust inttrust i.rndm_party##ib3.govmatch"

reg IMFQ2_2  i.imf##c.econideology  i.imf##c.inttrust  `othtreat' `controls_nolr'
margins, dydx(imf) at(econideology=(1(.5)5))
marginsplot, scheme(plotplain) recastci(rline) ciopts(lpattern(dash_dot)) recast(line) ///
 title(Effectiveness: HTE by economic ideology) xtitle("Economic ideology") ytitle("Treatment effect") aspectratio(0.5) yline(0, lpattern(dash))  ///
 addplot(hist econideology, bin(11) yaxis(2) percent yscale(range(0 100) axis(2)) ylabel("", axis(2)) ylabel(-.5 (.5) 1)  yscale(range(-.5 1) axis(1)) ytitle("", axis(2))) legend(off) saving(0b.gph, replace)

graph export FigureF9.png, replace

*** Figure F10
reg IMFQ2_3  i.imf##c.econideology  i.imf##c.inttrust  `othtreat' `controls_nolr'
margins, dydx(imf) at(econideology=(1(.5)5))
marginsplot, scheme(plotplain) recastci(rline) ciopts(lpattern(dash_dot)) recast(line) ///
 title(Sovereignty: HTE by economic ideology) xtitle("Economic ideology") ytitle("Treatment effect") aspectratio(0.5) yline(0, lpattern(dash))  ///
 addplot(hist econideology, bin(11) yaxis(2) percent yscale(range(0 100) axis(2)) ylabel("", axis(2)) ylabel(-1 (.5) .5)  yscale(range(-1 .5) axis(1)) ytitle("", axis(2))) legend(off) saving(0b.gph, replace)

graph export FigureF10.png, replace

log close